package com.platform.server.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.platform.server.dao.UserDao;
import com.platform.server.entity.EnterpriseInfo;
import com.platform.server.entity.Identity;
import com.platform.server.entity.User;
import com.platform.server.entity.Withdraw;
import com.platform.server.response.pojo.ReturnData;
import com.platform.server.service.UserService;
import com.szrca.ima.utils.StringTools;

@Controller
@RequestMapping("/user")
public class UserController {
	
	@Autowired
	private UserService userService;
	
	@Autowired
	private UserDao userDao;
	
	/**
	 * 人脸识别是否通过
	 */
	@ResponseBody
	@RequestMapping(value = "/updateFaceStatu",method = RequestMethod.POST)
	public Object updateFaceStatu(String statu,String id){
		return userService.updateFaceStatu(statu, id);
	}
	/**
	 * 升级描述
	 */
	@ResponseBody
	@RequestMapping(value = "/upgrade",method = RequestMethod.POST)
	public Object upgrade(){
		return userService.upgrade();
	}
	
	/**
	 * 升级描述
	 */
	@ResponseBody
	@RequestMapping(value = "/upgradeStop",method = RequestMethod.POST)
	public Object upgradeStop(String levelId){
		return userService.upgradeStop(levelId);
	}
	/**
	 * 微信登录
	 */
	@ResponseBody
	@RequestMapping(value = "/selectWxnum",method = RequestMethod.POST)
	public Object selectWxnum(String openid){
		return userService.selectWxnum(openid);
	}
	
	/**
	 * 填写推荐人手机
	 */
	@ResponseBody
	@RequestMapping(value = "/insertRecommendMobile",method = RequestMethod.POST)
	public Object insertRecommendMobile(String userid, String mobile){
		return userService.insertRecommendMobile(userid, mobile);
	}
	
	/**
	 * 查看推荐人手机号
	 */
	@ResponseBody
	@RequestMapping(value = "/selectRecommendMobile",method = RequestMethod.POST)
	public Object selectRecommendMobile(String userid){
		return userService.selectRecommendMobile(userid);
	}
	
	/**
	 * 查看个人照片
	 */
	@ResponseBody
	@RequestMapping(value = "/selectUserPhoto",method = RequestMethod.POST)
	public Object selectUserPhoto(String userid){
		return userService.selectUserPhoto(userid);
	}
	
	/**
	 * 注册获取验证码
	 */
	@ResponseBody
	@RequestMapping(value = "/getRegisterCode",method = RequestMethod.POST)
	public Object getRegisterCode(String mobile){
		return userService.getRegisterCode(mobile);
	}
	
	/**
	 * 用户注册
	 */
	@ResponseBody
	@RequestMapping(value = "/UserRegister",method = RequestMethod.POST)
	public Object UserRegister(String mobile,String code,String isEnter){
		return userService.UserRegister(mobile,code,isEnter);
	}
	
	/**
	 * 注册成功后设置密码
	 */
	@ResponseBody
	@RequestMapping(value = "/insertPassword",method = RequestMethod.POST)
	public Object insertPassword(String id, String password, String surePassword) throws Exception{
		return userService.insertPassword(id,password,surePassword);
	}
	
	/**
	 * 忘记密码获取验证码
	 */
	@ResponseBody
	@RequestMapping(value = "/getforgetPwdCode",method = RequestMethod.POST)
	public Object getforgetPwdCode(String mobile){
		return userService.getforgetPwdCode(mobile);
	}
	
	/**
	 * 忘记密码
	 */
	@ResponseBody
	@RequestMapping(value = "/forgetPassword",method = RequestMethod.POST)
	public Object forgetPassword(String mobile, String code, String password, String surePassword) throws Exception {
		return userService.forgetPassword(mobile, code, surePassword, surePassword);
	}
	
	/**
	 * 填写基本资料接口
	 */
	@ResponseBody
	@RequestMapping(value = "/setBaseInformation",method = RequestMethod.POST)
	public Object setBaseInformation(User user){
		return userService.setBaseInformation(user);
	}
	
	/**
	 * 修改基本资料
	 */
	@ResponseBody
	@RequestMapping(value = "/updateBaseInformation",method = RequestMethod.POST)
	public Object updateBaseInformation(User user){
		return userService.updateBaseInformation(user);
	}
	
	/**
	 * 登录获取验证码接口
	 */
	@ResponseBody
	@RequestMapping(value = "/getLoginCode",method = RequestMethod.POST)
	public Object getLoginCode(String mobile){
		return userService.getLoginCode(mobile);
	}
	
	/**
	 *  验证码登录
	 */
	@ResponseBody
	@RequestMapping(value = "/codeLogin",method = RequestMethod.POST)
	public Object codeLogin(String mobile,String code){
		return userService.codeLogin(mobile,code);
	}
	
	/**
	 * 密码登录
	 */
	@ResponseBody
	@RequestMapping(value = "/passwordLogin",method = RequestMethod.POST)
	public Object passwordLogin(String mobile,String password) throws Exception{
		return userService.passwordLogin(mobile,password);
	}
	
	/**
	 * 个人信息接口
	 */
	@ResponseBody
	@RequestMapping(value = "/selectUserInfo",method = RequestMethod.POST)
	public Object selectUserInfo(String id){
		return userService.selectUserInfo(id);
	}
	
	/**
	 * 绑定信息
	 */
	@ResponseBody
	@RequestMapping(value = "/selectUserBindingInfo",method = RequestMethod.POST)
	public Object selectUserBindingInfo(String id){
		return userService.selectUserBindingInfo(id);
	}
	
	/**
	 * 职业资格认证
	 */
	@ResponseBody
	@RequestMapping(value = "/insertJobCertification",method = RequestMethod.POST)
	public Object insertJobCertification(String job, String skill, String certification_photo,String id){
		return userService.insertJobCertification(job,skill,certification_photo,id);
	}
	
	/**
	 * 我的关注列表
	 */
	@ResponseBody
	@RequestMapping(value = "/selectmyInterestList",method = RequestMethod.POST)
	public Object selectmyInterestList(String id,Integer pageSize, Integer pageNo){
		if(pageSize==null||pageNo==null){
            pageNo =1;
            pageSize = 10;
        }
		return userService.selectmyInterestList(id,pageSize,pageNo);
	}
	
	/**
	 * 我的粉丝列表
	 */
	@ResponseBody
	@RequestMapping(value = "/selectMyFans",method = RequestMethod.POST)
	public Object selectMyFans(String id,Integer pageSize, Integer pageNo){
		if(pageSize==null||pageNo==null){
            pageNo =1;
            pageSize = 10;
        }
		return userService.selectMyFans(id,pageSize,pageNo);
	}
	
	/**
	 * 实名认证信息
	 */
	@ResponseBody
	@RequestMapping(value = "/selectAuthentication",method = RequestMethod.POST)
	public Object selectAuthentication(Integer id){
		return userService.selectAuthentication(id);
	}
	
	/**
	 * 企业认证
	 */
	@ResponseBody
	@RequestMapping(value = "/insertEnterpriseInfo",method = RequestMethod.POST)
	public Object insertEnterpriseInfo(EnterpriseInfo enterpriseInfo){
		return userService.insertEnterpriseInfo(enterpriseInfo);
	}
	
	/**
	 * 上传个人照片
	 */
	@ResponseBody
	@RequestMapping(value = "/updateUserPhoto",method = RequestMethod.POST)
	public Object updateUserPhoto(String userid,String photo){
		return userService.updateUserPhoto(userid,photo);
	}
	
	/**
	 * 上传个人视频
	 */
	@ResponseBody
	@RequestMapping(value = "/insertVideo",method = RequestMethod.POST)
	public Object insertVideo(String userid,String videoLink,String videoTime,String videoImage){
		return userService.insertVideo(userid,videoLink,videoTime,videoImage);
	}
	
	/**
	 * 关注用户
	 */
	@ResponseBody
	@RequestMapping(value = "/attentionUser",method = RequestMethod.POST)
	public Object attentionUser(String userid1,String userid2){
		return userService.attentionUser(userid1,userid2);
	}
	
	/**
	 * 提现申请
	 */
	@ResponseBody
	@RequestMapping(value = "/insertWithdrawApply",method = RequestMethod.POST)
	public Object insertWithdrawApply(Withdraw withdraw){
		return userService.insertWithdrawApply(withdraw);
	}
	
	/**
	 * 钱包明细
	 */
	@ResponseBody
	@RequestMapping(value = "/selectWalletInfo",method = RequestMethod.POST)
	public Object selectWalletInfo(String userid){
		return userService.selectWalletInfo(userid);
	}
	
	/**
	 * 取消关注用户
	 */
	@ResponseBody
	@RequestMapping(value = "/unfriendedUser",method = RequestMethod.POST)
	public Object unfriendedUser(String userid1,String userid2){
		return userService.unfriendedUser(userid1,userid2);
	}
	
	/**
	 * 查看我的推荐人列表
	 */
	@ResponseBody
	@RequestMapping(value = "/selectMyReferrerList",method = RequestMethod.POST)
	public Object selectMyReferrerList(String mobile){
		return userService.selectMyReferrerList(mobile);
	}
	
	/**
	 * 查看我的积分
	 */
	@ResponseBody
	@RequestMapping(value = "/selectMyIntegral",method = RequestMethod.POST)
	public Object selectMyIntegral(String userid){
		return userService.selectMyIntegral(userid);
	}
	
	/**
	 * 查看我的积分记录
	 */
	@ResponseBody
	@RequestMapping(value = "/selectIntegralRecord",method = RequestMethod.POST)
	public Object selectIntegralRecord(String userid,Integer pageSize, Integer pageNo){
		if(pageSize==null||pageNo==null){
            pageNo =1;
            pageSize = 10;
        }
		return userService.selectIntegralRecord(userid,pageSize,pageNo);
	}
	
	/**
	 * 我的账户
	 */
	@ResponseBody
	@RequestMapping(value = "/selectUserAccount",method = RequestMethod.POST)
	public Object selectUserAccount(String userid){
		return userService.selectUserAccount(userid);
	}
	
	/**
	 * 身份认证
	 */
	@ResponseBody
	@RequestMapping(value = "/insertIdentityAuthentication",method = RequestMethod.POST)
	public Object insertIdentityAuthentication(Identity i){
		return userService.insertIdentityAuthentication(i);
	}
	
	/**
	 * 删除个人照片接口
	 */
	@ResponseBody
	@RequestMapping(value = "/deleteUserPhoto",method = RequestMethod.POST)
	public Object deleteUserPhoto(String userid, String photo){
		return userService.deleteUserPhoto(userid,photo);
	}
	
	/**
	 * 查看职业资格证
	 */
	@ResponseBody
	@RequestMapping(value = "/selectJobCertification",method = RequestMethod.POST)
	public Object selectJobCertification(String userid){
		return userService.selectJobCertification(userid);
	}
	
	/**
	 * 修改登录密码
	 */
	@ResponseBody
	@RequestMapping(value = "/updateLoginPassword",method = RequestMethod.POST)
	public Object updateLoginPassword(String oldPassword,String newPassword,String surePassword,String userid) throws Exception{
		return userService.updateLoginPassword(oldPassword,newPassword,surePassword,userid);
	}
	
	/**
	 * 修改支付密码获取验证码
	 */
	@ResponseBody
	@RequestMapping(value = "/updatePayPasswordGetCode",method = RequestMethod.POST)
	public Object updatePayPasswordGetCode(String mobile){
		return userService.updatePayPasswordGetCode(mobile);
	}
	
	/**
	 * 意见反馈
	 */
	@ResponseBody
	@RequestMapping(value = "/insertFeedback",method = RequestMethod.POST)
	public Object insertFeedback(String userid,String content){
		return userService.insertFeedback(userid,content);
	}
	
	/**
	 * 获取个人基本资料
	 */
	@ResponseBody
	@RequestMapping(value = "/selectUserinfo",method = RequestMethod.POST)
	public Object selectUserinfo(Integer userid){
		return userService.selectUserinfo(userid);
	}
	
	/**
	 * 查看企业认证
	 */
	@ResponseBody
	@RequestMapping(value = "/selectCompany",method = RequestMethod.POST)
	public Object selectCompany(String userid){
		return userService.selectCompany(userid);
	}
	
	/**
	 * 修改用户经纬度
	 */
	@ResponseBody
	@RequestMapping(value = "/updateUserAddress",method = RequestMethod.POST)
	public Object updateUserAddress(Integer userid,String longitude,String latitude){
		if(userid == null || StringTools.isEmpty(longitude) || StringTools.isEmpty(latitude)){
			return new ReturnData(12,"参数有误");
		}
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("userid", userid);
		map.put("longitude", longitude);
		map.put("latitude", latitude);
		int flag = userDao.updateUserAddress(map);
		return new ReturnData(200,"成功");
	}
	
	/**
	 * 查看用户身份信息
	 */
	@ResponseBody
	@RequestMapping(value = "/selectUserIdInfo",method = RequestMethod.POST)
	public Object selectUserIdInfo(String userid){
		if(userid == null){
			return new ReturnData(12,"参数有误");
		}
		Map<String, Object> map = userDao.selectUserIdInfo(userid);
		return new ReturnData(map,200,"成功");
	}
	
	/**
	 * 添加下级
	 */
	@ResponseBody
	@RequestMapping(value = "/addUserGrade",method = RequestMethod.POST)
	public Object addUserGrade(User user){
		return userService.addUserGrade(user);
	}
	/**
	 * 根据手机号添加下级
	 */
	@ResponseBody
	@RequestMapping(value = "/addUserMobile",method = RequestMethod.POST)
	public Object addUserMobile(User user){
		return userService.addUserMobile(user);
	}
	/**
	 * 查询人脉
	 */
	@ResponseBody
	@RequestMapping(value = "/selectParentUser",method = RequestMethod.POST)
	public Object selectParentUser(User user){
		return userService.selectParentUser(user);
	}
	/**
	 * 查询下一级
	 * @param userid
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/selectOneUser",method = RequestMethod.POST)
	public Object selectOneUser(User user){
		return userService.selectOneUser(user);
	}
	/**
	 * 查询下二级
	 * @param userid
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/selectTwoUser",method = RequestMethod.POST)
	public Object selectTwoUser(User user){
		return userService.selectTwoUser(user);
	}
	/**
	 * 查询下级交易详情
	 */
	@ResponseBody
	@RequestMapping(value = "/selectdetail",method = RequestMethod.POST)
	public Object selectdetail( User user){
		return userService.selectdetail(  user);
	}
	/**
	 * 查询下级收益明细
	 */
	@ResponseBody
	@RequestMapping(value = "/selectUserDetail",method = RequestMethod.POST)
	public Object selectUserDetail(User user){
		return userService.selectUserDetail(user);
	}
	
	/**
	 *企业交易提成
	 */
	@ResponseBody
	@RequestMapping(value = "/selectEnter",method = RequestMethod.POST)
	public Object selectEnter(User user){
		return userService.selectEnter(user);
	}
	

	
}
